import projectSetting from '@/settings/projectSetting'
import { AxiosCanceler } from '@/utils/http/axios/axiosCancel'
import router from '..'

const { removeAllHttpPending } = projectSetting
let axiosCanceler: Nullable<AxiosCanceler>
if (removeAllHttpPending) {
  axiosCanceler = new AxiosCanceler()
}
router.beforeEach(async () => {
  // Switching the route will delete the previous request
  axiosCanceler?.removeAllPending()
  return true
})
